package ai.people.netmon.framework.domain.warning.vo;

import ai.people.netmon.framework.domain.warning.entity.WarningLabelTree;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 账户导航页数据
 *
 * @author yuanqinglong
 * @date 2022/8/10 10:56
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AccountNavigationVO {


    /**
     * id
     */
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Long id;

    /**
     * 父id
     */
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Long parentId;

    /**
     * 标签
     */
    private String labelName;

    /**
     * 标签值
     */
    private String labelValue;

    /**
     * 打标账号数
     */
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Integer accountCount = 0;

    /**
     * 打标账号发言数
     */
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Integer messageCount = 0;

    /**
     * 子集
     */
    private List<AccountNavigationVO> children;


    /**
     * 构建
     *
     * @param warningLabelTree 警告标签树
     * @param accountCount     账户数
     * @param messageCount     消息数
     * @param id               id
     * @param parenId          括弧id
     * @return {@link AccountNavigationVO}
     */
    public static AccountNavigationVO build(Long id, Long parenId, WarningLabelTree warningLabelTree, Integer accountCount, Integer messageCount) {
        AccountNavigationVO accountNavigationVO = new AccountNavigationVO();
        accountNavigationVO.setLabelName(warningLabelTree.getLabelName());
        accountNavigationVO.setLabelValue(warningLabelTree.getLabelValue());
        accountNavigationVO.setAccountCount(accountCount);
        accountNavigationVO.setMessageCount(messageCount);
        accountNavigationVO.setId(id);
        accountNavigationVO.setParentId(parenId);
        return accountNavigationVO;
    }


}
